home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.06.lha / AmiCAD / ARexx / ChargeRC.AmiCAD < prev    next >
Text File  |  2000-04-13  |  4KB  |  160 lines

  1. /* Tracé de la courbe de charge d'un condensateur.
  2. Version 1.00: 12 novembre 1998
  3. Version 1.01: 13 avril 2000 (modif SAVEALL)
  4. $VER: 1.01 (© R.Florac, 13 Avril 2000) */
  5.  
  6. options results     /* indispensable pour récupérer le résultat des macros */
  7.  
  8. signal on error     /* pour l'interception des erreurs */
  9. signal on syntax
  10.  
  11. clip=-1
  12. FIRSTSEL; obj=result
  13. if obj>0 then do
  14.     'TYPE(FIRSTSEL)'; type=result
  15.     if type=22 then do
  16.     'CLIPUNIT(5)'; clip=result
  17.     'COORDS(FIRSTSEL)'; coords=result
  18.     PARSE VAR coords x0 ',' y0 ',' x1 ',' y1
  19.     xg=minima(x0,x1); xd=maxima(x0,x1)
  20.     yh=minima(y0,y1); yb=maxima(y0,y1)
  21.     l=xd-xg+1; h=yb-yh+1
  22.     'NEXTSEL('obj')'; obj=result
  23.     end
  24. end
  25. else obj=1
  26.  
  27. if obj>0 then do
  28.     'MESSAGE("Dessinez et sélectionnez"+CHR(10)+"un rectangle dans"+CHR(10)+"lequel doit être"+CHR(10)+"intégrée la grille")'
  29.     call quitter
  30. end
  31.  
  32. ndh=5
  33. y1=yh+h
  34. x1=xg+ndh*(l%ndh)
  35. 'SAVEALL'
  36.  
  37. 'DELETE(FIRSTSEL):ROTATE(0,0)'
  38. /* Tracé des lignes verticales */
  39. do i=1 to 5
  40.     x2 = xg+i*(l/ndh)
  41.     x2 = x2%1
  42.     'DRAWMODE(1)'
  43.     do c=1 to 9
  44.     xc = x2-(l/ndh)/10*c
  45.     xc=xc%1
  46.     'DRAW('xc','yh','xc','yb')'
  47.     end
  48.     'DRAWMODE(2):DRAW('x2','yh','x2','yb')'
  49. end
  50. /* Repères verticaux */
  51. if h>300 then hc=2
  52. else hc=1
  53. if l>600 then lc=2
  54. else lc=1
  55. 'SETSCALE(0,'lc'*100,'hc'*100)'
  56. if lc=1 then lc=8
  57. else lc=16
  58. if hc=1 then hc=8
  59. else hc=16
  60.  
  61. if xg-5*lc<0 then do
  62.     'MESSAGE("Position grille incorrecte"+CHR(10)+"(Trop à gauche)")'
  63.     call quitter
  64. end
  65.  
  66. 'DRAWMODE(1):WRITE("0",'xg-lc-lc','yb+hc/2')'
  67. p=h%4
  68. 'WRITE("0,25",'xg-4*lc-lc','yh+3*p+hc/2')'
  69. 'WRITE("0,5",'xg-3*lc-lc','yh+2*p+hc/2')'
  70. 'WRITE("0,75",'xg-4*lc-lc','yh+p+hc/2')'
  71. 'WRITE("1",'xg-lc-lc','yh+hc/2')'
  72. /* Tracé des lignes horizontales */
  73. ndv=2
  74. do i=1 to ndv
  75.     y2 = yh+(i-1)*(h/ndv)
  76.     y2=y2%1
  77.     'DRAWMODE(2):DRAW('xg','y2','xd','y2')'
  78.     y2 = (yh)+i*(h/ndv)
  79.     y2 = y2%1
  80.     'DRAWMODE(1)'
  81.     do c=1 to 9
  82.     yc = y2-(h/ndv)/10*c
  83.     yc=yc%1
  84.     'DRAW('xg','yc','xd','yc')'
  85.     end
  86. end
  87. /* Repères horizontaux */
  88. n=0.5
  89. p=(l/10)%1
  90. ndv=yb+hc+hc/2
  91. 'WRITE("0",'xg-lc/2','ndv')'
  92. 'WRITE("0,5",'xg+p-lc','ndv')'
  93. 'WRITE("1RC",'xg+2*p-2*lc+lc/2','ndv')'
  94. 'WRITE("1,5",'xg+3*p-2*lc+lc/2','ndv')'
  95. 'WRITE("2RC",'xg+4*p-2*lc+lc/2','ndv')'
  96. 'WRITE("2,5",'xg+5*p-2*lc+lc/2','ndv')'
  97. 'WRITE("3RC",'xg+6*p-2*lc+lc/2','ndv')'
  98. 'WRITE("3,5",'xg+7*p-2*lc+lc/2','ndv')'
  99. 'WRITE("4RC",'xg+8*p-2*lc+lc/2','ndv')'
  100. 'WRITE("4,5",'xg+9*p-2*lc+lc/2','ndv')'
  101. 'WRITE("5RC",'xg+10*p-2*lc+lc/2','ndv')'
  102.  
  103. /* Tracé des axes */
  104. 'WRITE("U",'xg-lc*2','yh-hc')'
  105. 'WRITE("t",'xd+3*lc','ndv')'
  106. 'DRAWMODE(2):DRAW('xg','yb','xg','yh-hc'):DRAW('xg','yb','xd+2*lc','yb')'
  107. 'SETSCALE(0,100,100):CONVERT(PUTPART("Flèche",'xg-10','yh-hc-20'),1)'
  108. 'ROTATE(0,1):CONVERT(PUTPART("Flèche",'xd+2*lc','yb-10'),1):DRAWMODE(3)'
  109.  
  110. /* Tracé de la courbe de charge */
  111. if ~show('L','rexxmathlib.library') then
  112.     call addlib('rexxmathlib.library',0,-30)
  113. tau=l/5
  114. y0=yb; x0=xg
  115. do i=1 to l/5
  116.     y=h+(-h*exp(-5*i/tau))
  117.     y=y%1
  118.     'DRAW('x0','y0','x0+5','yb-y')'
  119.     x0=x0+5
  120.     y0=yb-y
  121. end
  122.  
  123. /* Tracé de la courbe de charge */
  124. y0=yh; x0=xg
  125. do i=1 to l/5
  126.     y=h+(-h*exp(-5*i/tau))
  127.     y=y%1
  128.     'DRAW('x0','y0','x0+5','yh+y')'
  129.     x0=x0+5
  130.     y0=yh+y
  131. end
  132.  
  133. call quitter
  134.  
  135. minima: procedure
  136.     parse arg v1,v2
  137.     if v1<v2 then return v1
  138.     return v2
  139. end
  140.  
  141. maxima: procedure
  142.     parse arg v1,v2
  143.     if v1>v2 then return v1
  144.     return v2
  145. end
  146.  
  147. quitter: procedure expose clip
  148.     if clip>=0 then 'CLIPUNIT('clip')'
  149.     exit
  150.  
  151. /* Traitement des erreurs, interruption du programme */
  152. syntax:
  153. erreur=RC
  154. 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  155. exit
  156.  
  157. error:
  158. 'MESSAGE("Erreur en ligne 'SIGL'")'
  159. exit
  160.